{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4d92d67a",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-2-fac042d8c31d>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-2-fac042d8c31d>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    ----\u001b[0m\n\u001b[1;37m        ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "----\n",
    "* 日期： 2022-10-26\n",
    "* python"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8f2a412",
   "metadata": {},
   "source": [
    "# 本周学习内容\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2619920c",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range (4):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "c550749a",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-36-c582a4a26ae9>, line 19)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-36-c582a4a26ae9>\"\u001b[1;36m, line \u001b[1;32m19\u001b[0m\n\u001b[1;33m    else:\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "product_list=[[\"0.自行车\",299],\n",
    "              [\"1.Iphone 14 pro\",8000],\n",
    "              [\"2.NFT 盲盒\",28],\n",
    "              [\"3.PYTHON书\",60]]\n",
    "shopping_car=[]\n",
    "Alipay=int(input(\"请输入您的余额\"))\n",
    "while True:\n",
    "    for i in range(4):\n",
    "        print(\"商品编号\"+str(i),product_list[i])\n",
    "    user_choice=input(\"请输入商品编号：\")\n",
    "\n",
    "    if user_choice.isdight():\n",
    "        if Alipay >= product_list[int(user_choice)][i]:\n",
    "            Alipay=Alipay-product_list[int(user_choice)][i]\n",
    "        shopping_car.append(product_list[int(user_choice)])\n",
    "        print(shopping_car)\n",
    "        print(\"您购买的商品已增加到购物车\")\n",
    "\n",
    "        else:\n",
    "            print(\"您的余额不足，请更换支付方式!\")\n",
    "    elif user_choice=\"q\":\n",
    "        print(\"您的购物车:\",shopping_car)\n",
    "        print(\"您的余额还有：\",Alipay)\n",
    "        break\n",
    "    else:\n",
    "        print(\"您输入的商品不存在或输入有误，请重新尝试\")\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8f3dfcca",
   "metadata": {},
   "outputs": [],
   "source": [
    "product_list=[\"自行车\",\"Iphone 14 pro\",\"NFT 盲盒\",\"PYTHON书\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c650838c",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unindent does not match any outer indentation level (<tokenize>, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<tokenize>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    shopping_car.append(product_list[int(user_choice)])\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m unindent does not match any outer indentation level\n"
     ]
    }
   ],
   "source": [
    " if Alipay >= product_list[int(user_choice)][i]:\n",
    "            Alipay=Alipay-product_list[int(user_choice)][i]\n",
    "        shopping_car.append(product_list[int(user_choice)])\n",
    "        prin(shopping_car)\n",
    "        print(\"您购买的商品已增加到购物车\")\n",
    "else:\n",
    "    print(\"您的余额不足，请更换支付方式!\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c7d161a",
   "metadata": {},
   "outputs": [],
   "source": [
    "elif user_choice=\"q\":\n",
    "        print(\"您的购物车:\",shopping_car)\n",
    "        print(\"您的余额还有：\",Alipay)\n",
    "        break\n",
    "    else:\n",
    "        print(\"您输入的商品不存在或输入有误，请重新尝试\")\n",
    "    \n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
